package com.worthtech.billportal.bean.base;

import java.io.Serializable;


/**
 * This is an object that contains data related to the acl_role table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="acl_role"
 */

public abstract class BaseRole  implements Serializable {

	public static String REF = "Role";
	public static String PROP_ROLE_DESC = "RoleDesc";
	public static String PROP_TYPE_I_D = "TypeID";
	public static String PROP_ROLE_NAME = "RoleName";
	public static String PROP_DATA_PERMISSION = "dataPermission";
	public static String PROP_ID = "Id";
	public static String PROP_DATA_PERMISSION_ID = "DataPermissionId";


	// constructors
	public BaseRole () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BaseRole (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	/**
	 * Constructor for required fields
	 */
	public BaseRole (
		java.lang.Integer id,
		java.lang.String roleName,
		java.lang.Integer typeID) {

		this.setId(id);
		this.setRoleName(roleName);
		this.setTypeID(typeID);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String roleName;
	private java.lang.String roleDesc;
	private java.lang.String dataPermissionId;
	private java.lang.Integer typeID;

	// many to one
	private com.worthtech.billportal.bean.Datapermission dataPermission;

	// collections
	private java.util.Set<com.worthtech.billportal.bean.Permission> permissions;
	private java.util.Set<com.worthtech.billportal.bean.User> users;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="native"
     *  column="id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: RoleName
	 */
	public java.lang.String getRoleName () {
		return roleName;
	}

	/**
	 * Set the value related to the column: RoleName
	 * @param roleName the RoleName value
	 */
	public void setRoleName (java.lang.String roleName) {
		this.roleName = roleName;
	}



	/**
	 * Return the value associated with the column: RoleDesc
	 */
	public java.lang.String getRoleDesc () {
		return roleDesc;
	}

	/**
	 * Set the value related to the column: RoleDesc
	 * @param roleDesc the RoleDesc value
	 */
	public void setRoleDesc (java.lang.String roleDesc) {
		this.roleDesc = roleDesc;
	}



	/**
	 * Return the value associated with the column: DataPermissionId
	 */
	public java.lang.String getDataPermissionId () {
		return dataPermissionId;
	}

	/**
	 * Set the value related to the column: DataPermissionId
	 * @param dataPermissionId the DataPermissionId value
	 */
	public void setDataPermissionId (java.lang.String dataPermissionId) {
		this.dataPermissionId = dataPermissionId;
	}



	/**
	 * Return the value associated with the column: TypeID
	 */
	public java.lang.Integer getTypeID () {
		return typeID;
	}

	/**
	 * Set the value related to the column: TypeID
	 * @param typeID the TypeID value
	 */
	public void setTypeID (java.lang.Integer typeID) {
		this.typeID = typeID;
	}



	/**
	 * Return the value associated with the column: DataPermissionId
	 */
	public com.worthtech.billportal.bean.Datapermission getDataPermission () {
		return dataPermission;
	}

	/**
	 * Set the value related to the column: DataPermissionId
	 * @param dataPermission the DataPermissionId value
	 */
	public void setDataPermission (com.worthtech.billportal.bean.Datapermission dataPermission) {
		this.dataPermission = dataPermission;
	}



	/**
	 * Return the value associated with the column: permissions
	 */
	public java.util.Set<com.worthtech.billportal.bean.Permission> getPermissions () {
		return permissions;
	}

	/**
	 * Set the value related to the column: permissions
	 * @param permissions the permissions value
	 */
	public void setPermissions (java.util.Set<com.worthtech.billportal.bean.Permission> permissions) {
		this.permissions = permissions;
	}

	public void addTopermissions (com.worthtech.billportal.bean.Permission permission) {
		if (null == getPermissions()) setPermissions(new java.util.TreeSet<com.worthtech.billportal.bean.Permission>());
		getPermissions().add(permission);
	}



	/**
	 * Return the value associated with the column: users
	 */
	public java.util.Set<com.worthtech.billportal.bean.User> getUsers () {
		return users;
	}

	/**
	 * Set the value related to the column: users
	 * @param users the users value
	 */
	public void setUsers (java.util.Set<com.worthtech.billportal.bean.User> users) {
		this.users = users;
	}

	public void addTousers (com.worthtech.billportal.bean.User user) {
		if (null == getUsers()) setUsers(new java.util.TreeSet<com.worthtech.billportal.bean.User>());
		getUsers().add(user);
	}




	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof com.worthtech.billportal.bean.Role)) return false;
		else {
			com.worthtech.billportal.bean.Role role = (com.worthtech.billportal.bean.Role) obj;
			if (null == this.getId() || null == role.getId()) return false;
			else return (this.getId().equals(role.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}


}